* STATE CODE FOR REPLICATION OF RESULTS FROM GEOFFREY WALLACE "ALLIANCES, INSTITUTIONAL DESIGN, AND THE DETERMINANTS OF MILITARY STRATEGY"
*	Supplementary version using coding of US and Russian observations for alliance variables to 1 (alliance) rather than 0 as in main results reported in paper.

version 8

* cd "appropriate data file"

use "alliances.dta", clear

* REGRESSION MODELS TO REPRODUCE RESULTS OF QUANTITATIVE ANALYSIS
*	Note that several robustness checks are included with the code for each respective model.

* set working directory for easier use of outreg to specific file folder
cd "C:\Documents and Settings\HP_Administrator\My Documents\DATA STATA 8\reitermeek_1999\alliances_tables_cmpsreview"


* ANALYSIS USING US/RUSSIAN OBS CODED AS "1"/ALLIANCE RATHER THAN MISSING FOR ALLIANCE VARIABLES.
* Results for replication of TABLE 3

* Model 1: Original final model from Reiter and Meek (their model 3)
probit mandummy polity steel direxp
est store RM
outreg using "alliance_table2.xls", nolabel ctitle(Baseline Model) bfmt(f,e,f,f) se replace
outreg using "alliance_table2_p.xls", nolabel ctitle(Baseline Model) bfmt(f,e,f,f) pvalue replace

*Model 2: Model 2 with overall alliances of US and SU -> using ATOP coding
probit mandummy polity steel direxp allyus_atop1_us1 allyrus_atop1_rus1
outreg using "alliance_table2.xls", nolabel ctitle(US and Russian Alliances) bfmt(f,e,f,f) se append
outreg using "alliance_table2_p.xls", nolabel ctitle(US and Russian Alliances) bfmt(f,e,f,f) pvalue append
est store ally

* Robust check using COW alliance coding
probit mandummy polity steel direxp allyus_cow_us1 allyrus_cow_rus1
* Robust check using ATOP coding where alliance only coded as 1 if offensive or defensive pact; nonaggression, neutrality and consultation pacts are coded as 0.
probit mandummy polity steel direxp allyus_atop2_us1 allyrus_atop2_rus1
* Robust check using COW alliance coding where only defensive pacts considered alliances; nonaggression and consultation pacts coded as 0.
probit mandummy polity steel direxp allyus_cow_def_us1 allyrus_cow_def_rus1


* Model 3: Use the military coordination variables for US and Russian allies (use 2nd version with 4 categorial variables)
probit mandummy polity steel direxp milinst2_us1 milinst2_rus1 
outreg using "alliance_table2.xls", nolabel ctitle(Alliance Institutionalization) bfmt(f,e,f,f) se append
outreg using "alliance_table2_p.xls", nolabel ctitle(Alliance Institutionalization) bfmt(f,e,f,f) pvalue append
est store milinst

* Robust check using 3 category milinst variable -> results are essentially the same
probit mandummy polity steel direxp milinst_us1 milinst_rus1
*	Note that 2 obs dropped because lmilinst_us1 predicts failures perfectly  

* Model 4: With institutionaliation dummies (4 categorical coding -> 0 no alliance; 1 low; 2 mid; 3 high -> no alliance is baseline category)
probit mandummy polity steel direxp hmilinst_us1 mmilinst_us1 lmilinst_us1 hmilinst_rus1 mmilinst_rus1 lmilinst_rus1

* Robust using only mid and high dummies -> results remain the same
*	use this specification since for comparative purposes the N remains the same as in other models.
probit mandummy polity steel direxp hmilinst_us1 mmilinst_us1 hmilinst_rus1 mmilinst_rus1
outreg using "alliance_table2.xls", nolabel ctitle(Alliance Institutionalization Level Dummies) bfmt(f,e,f,f) se append
outreg using "alliance_table2_p.xls", nolabel ctitle(Alliance Institutionalization Level Dummies) bfmt(f,e,f,f) pvalue append
est store milinst_dum


* MODEL 5 NATO/WARSAW 
probit mandummy polity steel direxp nato warsaw allyus_atop1_nonnato_us1 allyrus_atop1_nonws_rus1
outreg using "alliance_table2.xls", nolabel ctitle(NATO and Warsaw) bfmt(f,e,f,f) se append
outreg using "alliance_table2_p.xls", nolabel ctitle(NATO and Warsaw) bfmt(f,e,f,f) pvalue append
est store natows

* Robust check with alternate coding of Warsaw where Albania 1964 is coded as not a member (formally left in 1968 but de facto broke ties in early 1960s)
*	Note that do not need to change nonws variable since coding identical in both warsaw and warsaw2 specifications
*	Results remain the same
probit mandummy polity steel direxp nato warsaw2 allyus_atop1_nonnato_us1 allyrus_atop1_nonws_rus1

* Robust check using offensive and defensive ATOP pacts (atop2)
*	Results not change though nonwarsaw variable dropped because predicts failures perfectly
probit mandummy polity steel direxp  nato warsaw allyus_atop2_nonnato_us1 allyrus_atop2_nonws_rus1

* Robust check using COW coding
*	Results remain the same though non-warsaw variable dropped
probit mandummy polity steel direxp  nato warsaw allyus_cow_nonnato_us1 allyrus_cow_nonws_rus1

* Robust check using COW defense pacts as only type of alliance
*	Results remain the same though both non-nato and non-warsaw dropped
probit mandummy polity steel direxp nato warsaw allyus_cow_def_nonnato_us1 allyrus_cow_def_nonws_rus1


* Likelihood ratio tests for all main models
lrtest RM ally
lrtest RM milinst
lrtest RM milinst_dum
lrtest RM natows



*SOME OTHER ROBUSTNESS CHECKS

* Including Germany
*	In all cases the German variable is dropped because predicts failure perfectly (too few allies and little institutionalization)
*	Of the 4 cases of German allianes 1930-1945, 3 are of low institutionalization, 1 is mid, and none are high.
probit mandummy polity steel direxp allyus_atop1_us1 allyrus_atop1_rus1 allyg_atop1
probit mandummy polity steel direxp milinst_us1 milinst_rus1 milinst_g
probit mandummy polity steel direxp milinst2_us1 milinst2_rus1 milinst2_g


* Control for THREATS order to preclude possibility that threat is greater determinant of military strategy choice
*	Results generally do not change substantially; threat variables are not consistently significant across specifications.
* Model 1
probit mandummy polity steel direxp borders multmid midpart
outreg using "threat_table1.xls", nolabel ctitle(Baseline Model) bfmt(f,e,f,f) se replace
* Model 2
*	Russian variables become significant just shy of the 5% level (6%)
probit mandummy polity steel direxp allyus_atop1_us1 allyrus_atop1_rus1 borders multmid midpart
outreg using "threat_table1.xls", nolabel ctitle(US and Russian Alliances) bfmt(f,e,f,f) se append
* Model 3
probit mandummy polity steel direxp milinst2_us1 milinst2_rus1 borders multmid midpart
outreg using "threat_table1.xls", nolabel ctitle(Alliance Institutionalization) bfmt(f,e,f,f) se append
* Model 4
probit mandummy polity steel direxp hmilinst_us1 mmilinst_us1 hmilinst_rus1 mmilinst_rus1 borders multmid midpart
outreg using "threat_table1.xls", nolabel ctitle(Alliance Institutionalization Level Dummies) bfmt(f,e,f,f) se append
probit mandummy polity steel direxp hmilinst_us1 mmilinst_us1 lmilinst_us1 hmilinst_rus1 mmilinst_rus1 lmilinst_rus1 borders multmid midpart
* Model 5
probit mandummy polity steel direxp nato warsaw allyus_atop1_nonnato_us1 allyrus_atop1_nonws_rus1 borders multmid midpart
outreg using "threat_table1.xls", nolabel ctitle(NATO and Warsaw Pact) bfmt(f,e,f,f) se append

* Another way to evaluate threats is to run analysis using alliance institutionalization as the dependent variable
* Create a DV "hmilinst_1" that is 1 if either hmilinst_us0 or hmilinst_rus0 is 1 and 0 otherwise
probit  hmilinst_1  polity multmid midpart direxp borders steel trpqual
*	Steel significant. Of threat variables, borders is significant but negative and in opposite than expected direction.
probit  hmilinst_1  polity multmid midpart direxp borders steel trpqual rgdp96pc tpop



* Control for POPULATION as requested by Reviewer 3 (note that some missing values)
*	Note that results do not change substantially and population is never significant.
* Model 1
probit mandummy polity steel direxp tpop
* Model 2
probit mandummy polity steel direxp allyus_atop1_us1 allyrus_atop1_rus1 tpop
* Model 3
probit mandummy polity steel direxp milinst2_us1 milinst2_rus1 tpop
* Model 4
probit mandummy polity steel direxp hmilinst_us1 mmilinst_us1 hmilinst_rus1 mmilinst_rus1 tpop
probit mandummy polity steel direxp hmilinst_us1 mmilinst_us1 lmilinst_us1 hmilinst_rus1 mmilinst_rus1 lmilinst_rus1 tpop
* Model 5
probit mandummy polity steel direxp nato warsaw allyus_atop1_nonnato_us1 allyrus_atop1_nonws_rus1 tpop


* Control for Economic development and Population as requested by Reviewer 3
*	Use GDP/capita in constant 1996 $US (from Gleditsch trade data available from Eugene)
*	Use Population data in thousands from COW capabilities index
*	Note that N=112 only compared to N=187 in original models since GDP data have many missing values since data don't begin until post-WWII(1950).
*	General Results: Alliance coefficients in models 2 and 3 no longer significant (though still significant at p<.10) though this may be due in part to 
*		smaller sample size. Despite smaller sample size hmilinst and nato/warsaw remain significant as expect in models 4 and 5. In all models 
*		GDP/capita and population never reach standard levels of statistical significance.
* Model 1
probit mandummy polity steel direxp rgdp96pc tpop
* Model 2
probit mandummy polity steel direxp allyus_atop1_us1 allyrus_atop1_rus1 rgdp96pc tpop
* Model 3
probit mandummy polity steel direxp milinst2_us1 milinst2_rus1 rgdp96pc tpop
* Model 4
probit mandummy polity steel direxp hmilinst_us1 mmilinst_us1 hmilinst_rus1 mmilinst_rus1 rgdp96pc tpop
probit mandummy polity steel direxp hmilinst_us1 mmilinst_us1 lmilinst_us1 hmilinst_rus1 mmilinst_rus1 lmilinst_rus1 rgdp96pc tpop
* Model 5
probit mandummy polity steel direxp nato warsaw allyus_atop1_nonnato_us1 allyrus_atop1_nonws_rus1 rgdp96pc tpop






* RESULTS FOR REPLICATION OF TABLE 4 (Using Clarify) -> Predicted Probabilities of maneuver (substantive significance)

* Baseline model
estsimp probit mandummy polity steel direxp, dropsims
setx (polity steel) mean direxp 0
simqi
simqi fd(pr) changex(polity min max)
simqi fd(pr) changex(steel min max)
simqi fd(pr) changex(direxp min max)

setx polity min
simqi
setx polity max
simqi
setx polity mean
setx steel min
simqi
setx steel max
simqi
setx steel mean
setx direxp min
simqi
setx direxp max
simqi


* General alliance model
estsimp probit mandummy polity steel direxp allyus_atop1_us1 allyrus_atop1_rus1, dropsims
setx (polity steel) mean (direxp allyus_atop1_us1 allyrus_atop1_rus1) 0
simqi
simqi fd(pr) changex(polity min max)
simqi fd(pr) changex(steel min max)
simqi fd(pr) changex(direxp min max)
simqi fd(pr) changex(allyus_atop1_us1 min max)
simqi fd(pr) changex(allyrus_atop1_rus1 min max)

setx polity min
simqi
setx polity max
simqi
setx polity mean 
setx steel min
simqi
setx steel max
simqi
setx steel mean 
setx direxp min 
simqi
setx direxp max
simqi
setx direxp 0
setx allyus_atop1_us1 min
simqi
setx allyus_atop1_us1 max
simqi
setx allyus_atop1_us1 0
setx allyrus_atop1_rus1 min
simqi
setx allyrus_atop1_rus1 max
simqi
setx allyrus_atop1_rus1 0


* Institutionalization dummy model
estsimp probit mandummy polity steel direxp hmilinst_us1 mmilinst_us1 hmilinst_rus1 mmilinst_rus1, dropsims
setx (polity steel) mean (direxp hmilinst_us1 mmilinst_us1 hmilinst_rus1 mmilinst_rus1) 0
simqi
simqi fd(pr) changex(polity min max)
simqi fd(pr) changex(steel min max)
simqi fd(pr) changex(direxp min max)
simqi fd(pr) changex(hmilinst_us1 min max)
simqi fd(pr) changex(mmilinst_us1 min max)
simqi fd(pr) changex(hmilinst_rus1 min max)
simqi fd(pr) changex(mmilinst_rus1 min max)

setx polity min
simqi
setx polity max
simqi
setx polity mean 
setx steel min
simqi
setx steel max
simqi
setx steel mean 
setx direxp min 
simqi
setx direxp max
simqi
setx direxp 0
setx hmilinst_us1 min
simqi
setx hmilinst_us1 max
simqi
setx hmilinst_us1 0
setx mmilinst_us1 min
simqi
setx mmilinst_us1 max
simqi
setx mmilinst_us1 0
setx hmilinst_rus1 min
simqi
setx hmilinst_rus1 max
simqi
setx hmilinst_rus1 0
setx mmilinst_rus1 min
simqi
setx mmilinst_rus1 max
simqi
setx mmilinst_rus1 0


* NATO Warsaw model
estsimp probit mandummy polity steel direxp nato warsaw allyus_atop1_nonnato_us1 allyrus_atop1_nonws_rus1, dropsims
setx (polity steel) mean (direxp nato allyus_atop1_nonnato_us1 warsaw allyrus_atop1_nonws_rus1) 0
simqi
simqi fd(pr) changex(polity min max)
simqi fd(pr) changex(steel min max)
simqi fd(pr) changex(direxp min max)
simqi fd(pr) changex(nato min max)
simqi fd(pr) changex(allyus_atop1_nonnato_us1 min max)
simqi fd(pr) changex(warsaw min max)
simqi fd(pr) changex(allyrus_atop1_nonws_rus1 min max)

setx polity min
simqi
setx polity max
simqi
setx polity mean 
setx steel min
simqi
setx steel max
simqi
setx steel mean 
setx direxp min 
simqi
setx direxp max
simqi
setx direxp 0
setx nato min
simqi
setx nato max
simqi
setx nato 0
setx allyus_atop1_nonnato_us1 min
simqi
setx allyus_atop1_nonnato_us1 max
simqi
setx allyus_atop1_nonnato_us1 0
setx warsaw min
simqi
setx warsaw max
simqi
setx warsaw 0
setx allyrus_atop1_nonws_rus1 min
simqi
setx allyrus_atop1_nonws_rus1 max
simqi
setx allyrus_atop1_nonws_rus1 0




* TABLES FOR PREDICTED VS. ACTUAL VALUES/OUTCOMES-> replication of Table 1a pg.377 with alliance models

*Generate for Model 1 (Reiter and Meek original model 3)
probit mandummy polity steel direxp 

predict prman, pr

*Generate variable to be used as dichotomous for prediction success "prman1"
gen prman1 = 0

*recode prman1 to account for missing values in prman (since there are 3 missing values from 190 sample -> n=183)
recode prman1 0=. if prman==.

*recode prman1 to equal 1 if predicted probability of maneuver is over .5
recode prman1 0=1 if prman>.5

*Provides a cross tab table for predicted and actual strategy choice
tab prman1 mandummy
*According to RM, predict 172 out of 187 cases correctly (0.92)

drop prman prman1


*Generate for MODEL 2 (general alliance variables)
probit mandummy polity steel direxp allyus_atop1_us0 allyrus_atop1_rus0
predict prman, pr
gen prman1 = 0
recode prman1 0=. if prman==.
recode prman1 0=1 if prman>.5
tab prman1 mandummy
drop prman prman1

*Generate for MODEL 3 (Categorial milinst2)
probit mandummy polity steel direxp milinst2_us0 milinst2_rus0
predict prman, pr
gen prman1 = 0
recode prman1 0=. if prman==.
recode prman1 0=1 if prman>.5
tab prman1 mandummy
drop prman prman1


*Generate for MODEL 4 (milinst dummies)
probit mandummy polity steel direxp hmilinst_us0 mmilinst_us0 hmilinst_rus0 mmilinst_rus0
predict prman, pr
gen prman1 = 0
recode prman1 0=. if prman==.
recode prman1 0=1 if prman>.5
tab prman1 mandummy
*predicts 177 out of 187 cases correctly (0.95) -> 5 more cases than RM
drop prman prman1


*Generate for MODEL 5 (nato and warsaw; non-nato and non-warsaw)
probit mandummy polity steel direxp nato_us0 warsaw_rus0 allyus_atop1_nonnato_us0 allyrus_atop1_nonws_rus0
predict prman, pr
gen prman1 = 0
recode prman1 0=. if prman==.
recode prman1 0=1 if prman>.5
tab prman1 mandummy
drop prman prman1
